home *** CD-ROM | disk | FTP | other *** search
/ Chip 1996 April / CHIP 1996 aprilis (CD06).zip / CHIP_CD06.ISO / sac / pack / unrar-st.lzh / UNRAR.H < prev    next >
C/C++ Source or Header  |  1995-02-09  |  6KB  |  201 lines

  1. /******    *****   ******
  2.  **   **  **   **  **   **      Utilidad unRAR versión 1.00e
  3.  ******   *******  ******       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  4.  **   **  **   **  **   **       Versión portable y GRATUITA
  5.  **   **  **   **  **   **       ~~~~~~~~~~~~~~~~~~~~~~~~~~~
  6.  
  7.      Fichero de definiciones
  8.  
  9.    ELIMINE EL COMENTARIO DE ALGUNA DE LAS LINEAS DEL PRINCIPIO
  10.    PARA DEFINIR SU SISTEMA OPERATIVO.
  11. */
  12.  
  13. /*#define DOS*/          /* para compilar en PC DOS */
  14. /*#define OS2*/          /* para compilar en OS/2 */
  15. /*#define UNIX*/         /* para compilar en Unix */
  16. #define TOS          /* para compilar en ordenadores Atari ST/STE/TT/Falcon */
  17.  
  18. #include <stdio.h>
  19. #include <stdlib.h>
  20. #include <string.h>
  21. #include <ctype.h>
  22.  
  23. /*
  24.     En las definiciones genéricas siguientes puede definir el macro
  25.     opcional SETFILETIME para que UNRAR pueda manejar correctamente
  26.     el formato de fecha de su sistema operativo.
  27.  
  28.     El primer argumento de SETFILETIME es FILE *DestFile, y el
  29.     segundo un puntero a una estructura de fecha del DOS.
  30.  
  31.     Puede desactivar SETFILETIME con un ';' al final del nombre de
  32.     macro:
  33.  
  34.     #define SETFILETIME(FPtr,DosTimePtr)  ;
  35. */
  36.  
  37. /* definiciones genéricas DOS */
  38. #ifdef DOS
  39. #include <fcntl.h>
  40. #include <io.h>
  41. #include <dir.h>
  42. #include <alloc.h>
  43.  
  44. typedef unsigned char   UBYTE;       /*  variable sin signo de 8 bits  */
  45. typedef unsigned short  UWORD;       /*  variable sin signo de 16 bits */
  46. typedef unsigned long   UDWORD;      /*  variable sin signo de 32 bits */
  47. typedef long            SDWORD;      /*  variable con signo de 32 bits */
  48. typedef UBYTE huge *    HPBYTE;      /*  variable tipo puntero         */
  49.  
  50. #define MEMALLOC(Size)                farmalloc(Size)
  51. #define MEMFREE(Ptr)                  farfree(Ptr)
  52. #define MAKEDIR(Name)                 mkdir(Name)
  53. #define SETFILETIME(FPtr,DosTimePtr)  setftime(fileno(FPtr),DosTimePtr)
  54. #define PATHDIV                       '\\'
  55.  
  56. extern int _fmode=O_BINARY;
  57. #endif
  58.  
  59.  
  60. /* definiciones genéricas OS/2 */
  61. #ifdef OS2
  62. #include <fcntl.h>
  63.  
  64. typedef unsigned char   UBYTE;
  65. typedef unsigned short  UWORD;
  66. typedef unsigned long   UDWORD;
  67. typedef long            SDWORD;
  68. typedef UBYTE *         HPBYTE;
  69.  
  70. #define MEMALLOC(Size)                malloc(Size)
  71. #define MEMFREE(Ptr)                  free(Ptr)
  72. #define MAKEDIR(Name)                 mkdir(Name)
  73. #define SETFILETIME(FPtr,DosTimePtr)  setftime(fileno(FPtr),DosTimePtr)
  74. #define PATHDIV                       '\\'
  75.  
  76. extern int _fmode=O_BINARY;
  77. #endif
  78.  
  79.  
  80. /* definciones genéricas Unix */
  81. #ifdef UNIX
  82. #include <unistd.h>
  83.  
  84. typedef unsigned char   UBYTE;
  85. typedef unsigned short  UWORD;
  86. typedef unsigned long   UDWORD;
  87. typedef long            SDWORD;
  88. typedef UBYTE *         HPBYTE;
  89.  
  90. #define MEMALLOC(Size)                malloc(Size)
  91. #define MEMFREE(Ptr)                  free(Ptr)
  92. #define MAKEDIR(Name)                 mkdir(Name,0777)
  93. #define SETFILETIME(FPtr,DosTimePtr)  ;
  94. #define PATHDIV                       '/'
  95. #endif
  96.  
  97. /* definiciones génericas TOS */
  98. #ifdef TOS
  99. #include <tos.h>        /* Para los compiladores Turbo C/Pure C y Lattice C. */
  100. /*#include <osbind.h>*/    /* Para el resto de compiladores. */
  101.  
  102. typedef unsigned char   UBYTE;
  103. typedef unsigned short  UWORD;
  104. typedef unsigned long   UDWORD;
  105. typedef long            SDWORD;
  106. typedef UBYTE *         HPBYTE;
  107.  
  108. #define MEMALLOC(Size)                malloc(Size)
  109. #define MEMFREE(Ptr)                  free(Ptr)
  110. #define MAKEDIR(Name)                 mkdir(Name)
  111. #define SETFILETIME(FPtr,DosTimePtr)  ;
  112. #define PATHDIV                       '\\'
  113. #endif
  114.  
  115. #define  UNP_VER       15       /* versión actual del método de descompresión */
  116.  
  117. /* atributos de ficheros específicos del DOS */
  118. #define DOSFA_RDONLY   0x01
  119. #define DOSFA_HIDDEN   0x02
  120. #define DOSFA_SYSTEM   0x04
  121. #define DOSFA_LABEL    0x08
  122. #define DOSFA_DIREC    0x10
  123. #define DOSFA_ARCH     0x20
  124.  
  125. /* Códigos de retorno */
  126. enum { SUCCESS,WARNING,FATAL_ERROR,CRC_ERROR,LOCK_ERROR,WRITE_ERROR,
  127.        OPEN_ERROR,USER_ERROR,MEMORY_ERROR,USER_BREAK=255 };
  128.  
  129. /* Estados para la finalización */
  130. enum { SD_MEMORY=1,SD_FILES=2 };
  131.  
  132. /* Estados para comparación de trayectorias */
  133. enum { COMPARE_PATH,NOT_COMPARE_PATH };
  134.  
  135. /* flags de la cabecera de archivo */
  136. #define  MHD_MULT_VOL       1
  137. #define  MHD_COMMENT        2
  138. #define  MHD_LOCK           4
  139. #define  MHD_SOLID          8
  140.  
  141. /* flags de la cabecera de fichero */
  142. #define  LHD_SPLIT_BEFORE   1
  143. #define  LHD_SPLIT_AFTER    2
  144. #define  LHD_PASSWORD       4
  145. #define  LHD_COMMENT        8
  146. #define  SKIP_IF_UNKNOWN    0x4000
  147. #define  LONG_BLOCK         0x8000
  148.  
  149. /* tipos de bloques del archivo */
  150. enum { ALL_HEAD=0,MARK_HEAD=0x72,MAIN_HEAD=0x73,FILE_HEAD=0x74,
  151.        COMM_HEAD=0x75 };
  152.  
  153. /* Código de S.O. */
  154. enum { MS_DOS=0 };
  155.  
  156. /* Códigos de error */
  157. enum { EEMPTY = -1,EWRITE = 1,EREAD,EOPEN,ECLOSE,ESEEK,EMEMORY,EARCH };
  158.  
  159. struct dos_ftime {
  160.   unsigned ft_tsec  : 5;
  161.   unsigned ft_min   : 6;
  162.   unsigned ft_hour  : 5;
  163.   unsigned ft_day   : 5;
  164.   unsigned ft_month : 4;
  165.   unsigned ft_year  : 7;
  166. };
  167.  
  168. /* definiciones de cabeceras */
  169.  
  170. struct MarkHeader
  171. {
  172.   UBYTE Mark[5];
  173.   UWORD HeadSize;
  174. };
  175.  
  176. struct ArchiveHeader
  177. {
  178.   UWORD  HeadCRC;
  179.   UBYTE  HeadType;
  180.   UWORD  Flags;
  181.   UWORD  HeadSize;
  182.   UBYTE  Reserved[6];
  183. };
  184.  
  185. struct FileHeader
  186. {
  187.   UWORD  HeadCRC;
  188.   UBYTE  HeadType;
  189.   UWORD  Flags;
  190.   UWORD  HeadSize;
  191.   UDWORD PackSize;
  192.   UDWORD UnpSize;
  193.   UBYTE  HostOS;
  194.   UDWORD FileCRC;
  195.   struct dos_ftime FileTime;
  196.   UBYTE  UnpVer;
  197.   UBYTE  Method;
  198.   UWORD  NameSize;
  199.   UDWORD FileAttr;
  200. };
  201.